namespace SPI.AgentServer.Services.Export;

/// <summary>
/// 导出服务接口
/// </summary>
public interface IExportService
{
    /// <summary>
    /// 导出为 Excel 文件
    /// </summary>
    /// <param name="data">要导出的数据（动态类型）</param>
    /// <param name="fileName">文件名（不含扩展名）</param>
    /// <param name="sheetName">工作表名称</param>
    /// <returns>文件流和内容类型</returns>
    Task<ExportResult> ExportToExcelAsync(object data, string fileName, string? sheetName = null);

    /// <summary>
    /// 导出为 Excel（带多个工作表）
    /// </summary>
    /// <param name="sheets">多个工作表数据</param>
    /// <param name="fileName">文件名（不含扩展名）</param>
    /// <returns>文件流和内容类型</returns>
    Task<ExportResult> ExportToExcelMultiSheetAsync(Dictionary<string, object> sheets, string fileName);

    /// <summary>
    /// 导出为 CSV 文件
    /// </summary>
    /// <param name="data">要导出的数据</param>
    /// <param name="fileName">文件名（不含扩展名）</param>
    /// <returns>文件流和内容类型</returns>
    Task<ExportResult> ExportToCsvAsync(object data, string fileName);
}

/// <summary>
/// 导出结果
/// </summary>
public class ExportResult
{
    /// <summary>
    /// 文件流
    /// </summary>
    public MemoryStream Stream { get; set; } = new();

    /// <summary>
    /// 内容类型
    /// </summary>
    public string ContentType { get; set; } = string.Empty;

    /// <summary>
    /// 文件名
    /// </summary>
    public string FileName { get; set; } = string.Empty;

    /// <summary>
    /// 文件大小（字节）
    /// </summary>
    public long FileSize => Stream.Length;
}




